import { createRouter,createWebHashHistory,createWebHistory,createMemoryHistory} from "vue-router";
// 
//1.声明routers配置,一个routes是一个数组 , routes对象里面的基本属性由path和component组成  

//2.配置routes
let routes =[

    // 配置路径
  
    {
        path:"/",
        component:()=>import("../page/home/index.vue"),
        name:'/',
        meta: { 
            // meta属性随意添加
            name:"导航首页"
         },
        children:[
            {
         path:"discover",
         name:"discover",
         meta:{
            name:'发现'
        },
        component:()=>import("../page/discover/index.vue"),
        children:
            [
               {
                path:'playlist',
                name:'playlist', //name具名路由的属性
                meta:{
                    name:'歌单'
                },
                component:()=>import('../page/discover/playlist/index.vue'),
               }
            ]
            },
            {
                path:"mine",
                name:'mine',
                meta:{
                    name:'个人中心'
                },
                component:()=>import("../page/mine/index.vue"),
            },
            {
                props: true, //路由解耦合
                path:"friend/:id",
                name:'friend',
                meta:{
                    name:'朋友'
                },
                component:()=>import("../page/friend/index.vue"),
            },
        ]
    },
    
    {
        path:"/login",
        name:'login',
        meta:{
            name:'登录页'
        },
        component:()=>import("../page/login/index.vue"),
      
    },
   
]
// 创建路由
const router =createRouter(
    {
     history:createWebHashHistory("/base"), //路由模式 (基础路径)
     routes //挂进来 
    }
)
  //导出路由 暴露router，让别人能拿到
export default  router;
